import base64
import json
import re
import time
import requests

from common import settings


def main():
    headers = {
        "accept": "*/*",
        "accept-language": "zh-CN,zh;q=0.9",
        # "bnc-uuid": "d3bf9f72-e28e-466a-8d4b-a57f6581a4cb",
        "cache-control": "no-cache",
        "clienttype": "web",
        "content-type": "application/json",
        # "csrftoken": "d41d8cd98f00b204e9800998ecf8427e",
        # "device-info": "eyJzY3JlZW5fcmVzb2x1dGlvbiI6IjE5MjAsMTA4MCIsImF2YWlsYWJsZV9zY3JlZW5fcmVzb2x1dGlvbiI6IjE5MjAsMTAzMiIsInN5c3RlbV92ZXJzaW9uIjoiV2luZG93cyAxMCIsImJyYW5kX21vZGVsIjoidW5rbm93biIsInN5c3RlbV9sYW5nIjoiemgtQ04iLCJ0aW1lem9uZSI6IkdNVCswODowMCIsInRpbWV6b25lT2Zmc2V0IjotNDgwLCJ1c2VyX2FnZW50IjoiTW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzEyNC4wLjAuMCBTYWZhcmkvNTM3LjM2IiwibGlzdF9wbHVnaW4iOiJQREYgVmlld2VyLENocm9tZSBQREYgVmlld2VyLENocm9taXVtIFBERiBWaWV3ZXIsTWljcm9zb2Z0IEVkZ2UgUERGIFZpZXdlcixXZWJLaXQgYnVpbHQtaW4gUERGIiwiY2FudmFzX2NvZGUiOiIyOTVmOWVjYyIsIndlYmdsX3ZlbmRvciI6Ikdvb2dsZSBJbmMuIChJbnRlbCkiLCJ3ZWJnbF9yZW5kZXJlciI6IkFOR0xFIChJbnRlbCwgSW50ZWwoUikgVUhEIEdyYXBoaWNzIDYzMCAoMHgwMDAwOUJDOCkgRGlyZWN0M0QxMSB2c181XzAgcHNfNV8wLCBEM0QxMSkiLCJhdWRpbyI6IjEyNC4wNDM0NzUyNzUxNjA3NCIsInBsYXRmb3JtIjoiV2luMzIiLCJ3ZWJfdGltZXpvbmUiOiJBc2lhL1NoYW5naGFpIiwiZGV2aWNlX25hbWUiOiJDaHJvbWUgVjEyNC4wLjAuMCAoV2luZG93cykiLCJmaW5nZXJwcmludCI6IjU3ZTM1ZDU3MWFiOGU2NWRmMDNkYWE3OTE4MDQxYjkxIiwiZGV2aWNlX2lkIjoiIiwicmVsYXRlZF9kZXZpY2VfaWRzIjoiIn0=",
        # "fvideo-id": "331bb7e3ae7cab49a6136d53f817c25dd1c63f52",
        "fvideo-token": "CRicDEpzRRA8LLYmf62kX6FByBPJRJb2R3TpzoEHj0sXS7Q0NXUWR3QEXPzUBTMJJY3qsihTuNOmsfpXxafV2NyZxD5DiADyIOYO9vt42j1xw/PxPZkuqNi5Sf6aqHxKwnm5TJb6VgRyhnS7lHkzEBUfmgOSwrR47uOZ0+/UO0mAqKFap+9i73EtrVKpobuL0=52",
        # "fvideo-token": "",
        "lang": "zh-CN",
        "origin": "https://accounts.binance.com",
        "pragma": "no-cache",
        # "priority": "u=1, i",
        # "referer": "https://accounts.binance.com/zh-CN/login?loginChannel=&return_to=aHR0cHM6Ly93d3cuYmluYW5jZS5jb20vemgtQ04vbXkvZGFzaGJvYXJk",
        # "sec-ch-ua": "\"Chromium\";v=\"124\", \"Google Chrome\";v=\"124\", \"Not-A.Brand\";v=\"99\"",
        # "sec-ch-ua-mobile": "?0",
        # "sec-ch-ua-platform": "\"Windows\"",
        # "sec-fetch-dest": "empty",
        # "sec-fetch-mode": "cors",
        # "sec-fetch-site": "same-origin",
        "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
        "x-passthrough-token": "",
        # "x-trace-id": "6303d96b-1246-421c-b7a3-e287a8369944",
        # "x-ui-request-trace": "6303d96b-1246-421c-b7a3-e287a8369944"
    }
    cookies = {
        "theme": "dark",
        "_ga": "GA1.1.732756774.1714981822",
        "bnc-uuid": "d3bf9f72-e28e-466a-8d4b-a57f6581a4cb",
        "sajssdk_2015_cross_new_user": "1",
        "sensorsdata2015jssdkcross": "%7B%22distinct_id%22%3A%2218f4ceff308cee-0f413f23bfaa988-26001d51-2073600-18f4ceff309150d%22%2C%22first_id%22%3A%22%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%7D%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMThmNGNlZmYzMDhjZWUtMGY0MTNmMjNiZmFhOTg4LTI2MDAxZDUxLTIwNzM2MDAtMThmNGNlZmYzMDkxNTBkIn0%3D%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%22%2C%22value%22%3A%22%22%7D%2C%22%24device_id%22%3A%2218f4ceff308cee-0f413f23bfaa988-26001d51-2073600-18f4ceff309150d%22%7D",
        "lang": "zh-cn",
        "se_sd": "FgNEgRBBbHDVw8F1UVwYgZZVhCBkDEVUlFWVfVkJ1VdWwU1NWUkH1",
        "se_gd": "VgXAFBg5WDUEAkOQIUhRgZZERAVtUBVUlBTVfVkJ1VdWwAlNWUIF1",
        "userPreferredCurrency": "USD_USD",
        "se_gsd": "Yys2LBl4IDckBlc0IyIhNAQ9GVwYDwYbVVhBW1ZVUlVbDVNT1",
        "BNC_FV_KEY": "331bb7e3ae7cab49a6136d53f817c25dd1c63f52",
        "BNC_FV_KEY_T": "101-qojQkfdhzjLqX7qZa5h8oPSc0H0kh%2FMwFfUvTU1JFwfeeoFi%2FbQjJeirG%2FijSMgpnszIDpMA3xvuwYHZ6SbD2g%3D%3D-ndM97Exn62%2Boa1d%2BdN49Uw%3D%3D-61",
        "BNC_FV_KEY_EXPIRE": "1715004345710",
        "OptanonConsent": "isGpcEnabled=0&datestamp=Mon+May+06+2024+16%3A05%3A45+GMT%2B0800+(%E4%B8%AD%E5%9B%BD%E6%A0%87%E5%87%86%E6%97%B6%E9%97%B4)&version=202402.1.0&browserGpcFlag=0&isIABGlobal=false&hosts=&consentId=b0f5d51f-0820-479e-a1ce-6dab52bdde51&interactionCount=1&isAnonUser=1&landingPath=NotLandingPage&groups=C0001%3A1%2CC0003%3A1%2CC0004%3A1%2CC0002%3A1&AwaitingReconsent=false",
        "_ga_3WP50LGEEC": "GS1.1.1714981822.1.1.1714983101.45.0.0"
    }
    url = "https://accounts.binance.com/bapi/accounts/v1/public/account/security/bizCheck"
    data = {
        "mobile": "5527998650648",
        "mobileCode": "BR",
        "callingCode": "55",
        "bizType": "login",
        "sessionId": "2A114156316A622754B26AC0D765A9163EBD1015"
    }
    data = json.dumps(data, separators=(',', ':'))
    response = requests.post(url, headers=headers
                             # , cookies=cookies,
                             , data=data, proxies=settings.proxies)

    print(response.text)
    print(response)


if __name__ == '__main__':
    main()
